class Solution(object):
    def minOperations(self, s):
        if s[0] == '0':
            now0 = 0
            now1 = 1
        else:
            now0 = 1
            now1 = 0
        for i in range(1, len(s)):
            if s[i] == '0':
                next0 = now1
                next1 = now0 + 1
            else:
                next0 = now1 + 1
                next1 = now0
            now0 = next0
            now1 = next1
        return min(now0, now1)
